mod front_of_house {
    mod hosting {
        fn add_to_waitlist() {}
        fn seat_at_table() {}
    }

    mod serving {
        fn take_order() {}
        fn serve_order() {}
        fn take_payment() {}
    }
}

use


pub fn eat_at_restaurant() {

    // 绝对路径
    crate::front_of_house::hosting::add_to_waitlist();

    // 相对路径
    front_of_house::hosting::add_to_waitlist();
}

// rust  内新建的mod和struct都是默认private，如果要给到其他的地方访问需要加pub修饰，enum 则不需要在变量加pub修饰
mod back_of_house {
    pub struct Breakfast {
        pub toast: String,
        seasonal_fruit: String,
    }

    impl Breakfast {
        pub fn summer(toast: &str) -> Breakfast {
            Breakfast {
                toast: String::from(toast),
                seasonal_fruit: String::from("peaches"),
            }
        }
    }
}

pub fn eat_at_restaurant_one() {
    let mut meal = back_of_house::Breakfast::summer("Rye");
    meal.toast = String::from("Wheat");
    println!("I'd like {} toast please",meal.toast);
    // 需要是公共的才可以访问
    // meal.seasonal_fruit = String::from("blueberries");
}

mod front_of_house_one {
    pub mod hosting {
        pub fn add_to_waitlist() {

        }
    }
}
// 使用use将路径名称导入到作用域厚，该名称在此作用内是私有的
// pub use 重导出
// 1.将条目引入作用域   2.该条目可以被外部代码引入到他们的作用域
pub use crate::front_of_house_one::hosting;
// use crate::front_of_house_one::hosting;

pub fn eat_at_restaurant_two() {
    hosting::add_to_waitlist();
    hosting::add_to_waitlist();
    hosting::add_to_waitlist();
}

use std::collections::HashMap;
use std::fmt;
use std::io;

use std::fmt::Result;
use std::io::Result as IoResult;
pub fn invoke_map() {
    let mut map = HashMap::new();
    map.insert(1,5);

    // fn f1() -> fmt::Result {}
    // fn f2() -> io::Result {}
    fn f3() -> Result {}
    fn f4() -> IoResult<T> {}
}


// use std::io;
// use std::io::Write;
// 若引用的是自身就用self来代替
use std::{self,Write};
// 全部引用，但是慎用
use std::collections::*;
use crate::hosting::add_to_waitlist;
// 应用场景   1.测试  将所有被测试代码引入到tests模块中  2.有时候被用于预导入（prelude）模块


pub mod abondon;

pub use crate::abondon::bill;
pub fn invoke_bill() {
    bill::hosting_one();
}
